<template>
  <div class="searchpage">
    <form action="/">
      <van-search
        v-model="value"
        placeholder="搜索商品"
        show-action
        background="#fff"
        @search="onSearch"
        @cancel="onCancel"
      />
    </form>
    <div class="keyword">
      <div class="bk">
        <div class="fs14">历史搜索</div>
        <div @click="onSearch" v-for="item in keyword.history" class="key">{{item}}</div>
      </div>
      <div class="bk">
        <div  class="fs14">热门搜索</div>
        <div @click="onSearch" v-for="item in keyword.hot" class="key">{{item}}</div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "search",
    data: function () {
      return {
        value: '',
        keyword:{
          history:["苹果","奇异果","香蕉"],
          hot:["苹果","奇异果","香蕉","大蒜"]
        }
      }
    },
    methods: {
      onSearch: function () {
        this.$router.push('/search/result')
      },
      onCancel: function () {
        this.$router.go(-1)
      }
    }
  }
</script>

<style lang="less">
  .searchpage .van-cell {
    background-color: #f5f5f5;
  }

</style>
<style scoped lang="less">
  .bk{
    padding: 10px;
  }
  .keyword{
    height:calc(100vh - 50px) ;
    background-color: #fff;
    border-top: 1px solid @_lgrey ;
  }
  .keyword .fs14{
    line-height: 30px;
  }
  .key{
    display:inline-block ;
    padding:5px 15px;
    margin: 5px;
    background-color: @_lgrey;
    color: @_blk;
    border-radius: 5px;
  }
</style>
